<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //用正则验证一个数是否在0-255之间

        // window.onload = function () {
        //     function fn(min, max) {

        //         var str = parseInt(Math.random() * (max + 1 - min)) + min;
        //         return str;
        //     }
        //     var s = setInterval(function () {
        //         var str = fn(0, 255)

        for (var i = 0; i <= 255; i++) {
            var str = i;
            var reg = /^([0-9])|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])$/
            // if(!reg.test(str)){
            //     console.log(i);
            // }
            console.log(reg.test(str))
        }
// var  reg  =/a|bc/
                // var str = parseInt(prompt("请输入一个0-255之间的数", 256));
                // var reg = /^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-5][0-5])$/
                // console.log(reg.test(str))
            // }, 10)
        // }
    </script>
</head>

<body>

</body>

</html>